<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="UTF-8"%>
<%@page import="java.sql.Connection" %>
<%@page import="java.sql.Statement" %>
<%@page import="java.sql.PreparedStatement" %>
<%@page import="java.sql.ResultSet" %>
<%@page import="java.sql.SQLException" %>
<%@page import="java.util.List" %>
<%@page import="java.util.ArrayList" %>
<%@page import="bean.Log" %>

<%@page import="utils.DBCPUtil" %>
<%@page import="org.apache.commons.dbutils.QueryRunner" %>
<%@page import="org.apache.commons.dbutils.handlers.BeanHandler" %>
<%@page import="org.apache.commons.dbutils.handlers.BeanListHandler" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>日志管理</title>
<script src="js/ajax.js"></script>
<style>
th{
	height:30px;
}
td{
  height:30px;
}

input{
	width:100%;
	height:25px;
}
a{
	text-decoration: none;
}
li a{
	color:#555555;
	font-size:20px;
	border:1px;
	display:block;
	width:100%;
	height:30px;
	padding-top:10px;
    text-align: center;
}

li a:hover{
    background-color:#E7E7E7;
}

button{
	width:50px;
	margin:5px;
	margin-left:7%;
}

tr.scrolltype{
	display:table; 
	width: 100%; 
	height:30px;
	table-layout:fixed;
}

.first{
	width:80px;
}
</style>
</head>
<body>
<div class="title" style="width:100%; height:80px; background-color:#7080A6; color:white; text-align:center; padding-top:8px; box-sizing:border-box;">
	<h1 class="thetitle">邮件服务器管理界面</h1>
</div>

<div class="left" style="float:left; background-color:#D2DFF0; width:15%; height:500px;"> 
	<ul style="list-style:none; margin:0px; padding:0px; margin-top:20px;">
		<li><a href="serverManage.jsp">服务器管理</a></li>
		<li><a href="userManage.jsp">用户管理</a></li>
		<li><a href="logManage.jsp" style="background-color:#E7E7E7">日志管理</a></li>
		<li><a href="sendMails.jsp">群发邮件</a></li>
		
	</ul>
</div>
<div class="right" style="float:left; width:85%; height:500px;">
	<form action="./Login_out">
			<button style="margin-left: 95%; margin-top: 3px; display: inline;"
				type="submit">退出</button>
	</form>
	
	
	<div id="action" style="float:left; width:100%;">
		<p style="margin-left:5%; margin-top:30px; font-size:16px; color:#7080A6;">查询日志：</p>
		<table  cellspacing="0"  style="background-color:#F7F7F7; width:90%; text-align:right;  margin-left:5%; padding:10px; ">
			<tr>
				
					<td style="width:10%;">查询关键字：</td>
					<td style="text-align:left;">
						<input id="input" style="width:50%;"placeholder="请输入关键字"/>
					</td>
					<td><button type="button" onclick="searchLog()">检索</button></td>
					
			</tr>
			<tr>
				<td>查询条件：</td>
				<td style="text-align:left;">
					<select id="condition" style="height:25px;">
						<option value="executor">操作者</option>
						<option value="execution">操作事项</option>
						<option value="date">时间</option>
						<option value="state">状态</option>
					</select>
				</td>
				<td><button type="button" onclick="showallLog()" style="width:100px;">显示所有日志</button></td>
			</tr>
		</table>
	</div>
	
	<div id="loglist" style="float:left; width:100%;">
		<p style="margin-left:5%; margin-top:10px; font-size:16px; color:#7080A6;">日志列表：</p>
		<table  border="1px" cellspacing="0" style="width:90%;  margin-left:5%; background-color:#F7F7F7;">
			<thead style="display:table; width: calc(100% - 1em); table-layout:fixed; background-color:#BABABA;">
				<tr>
					<th class="first">序号</th>
					<th>操作者</th>
					<th>操作事项</th>
					<th>时间</th>
					<th>状态</th>
				</tr>
			</thead>
			
			<tbody id="datalist" style="display:block; height:200px; overflow-y:scroll; text-align:center;">
				<%
				QueryRunner qr = new QueryRunner(DBCPUtil.getDataSource());
				List<Log> loglist = new ArrayList<Log>();
				loglist = qr.query("select * from log", new BeanListHandler<>(Log.class));
					int count=0;
					for (Log l : loglist) {
					count++;
				%>
				<tr class="scrolltype">
				<td class="first"><%=count%></td>
				<td><%=l.getExcutor()%></td>
				<td><%=l.getExcution()%></td>
				<td><%=l.getModify_time()%></td>
				<td><%=l.isState()%></td>
				</tr>
				<%
				}
				%>
			</tbody>
		</table>
	</div>
</div>

<div class="copyright" style="clear:both; width:100%; height:50px; background-color:#7080A6; color:white; text-align:center; box-sizing:border-box; padding-top:1px;">
	<h3>版权所有：邮件服务器</h3>
</div>
</body>
</html>